<template>
  <section class="setting-avatar">
    <div class="inner">
        <Form :model="formItem" label-position="right" :label-width="150">
            <FormItem label="当前密码：">
                <Input v-model="formItem.oldpwd" style="width: 300px" type="password"></Input>
            </FormItem>
            <FormItem label="设置新密码：">
                <Input v-model="formItem.newpwd" style="width: 300px" type="password"></Input>
                &nbsp;&nbsp;
                <span>密码长度为6~16个字符</span>
            </FormItem>
            <FormItem label="确认新密码：">
                <Input v-model="formItem.confirpwd" style="width: 300px" type="password"></Input>
            </FormItem>
        </Form>
        <div style="padding-left: 100px">
            <Button type="primary" size="large" style="width: 206px" @click="subimt">保存</Button>
        </div>
    </div>
  </section>
</template>

<script>
import MsgItem from '@/components/ListItem/MsgItem'
export default {
  name: 'SettingAvatar',
  components: {
      MsgItem
  },
   data () {
      return {
          formItem: {}
      }
   },
    created () {
    },
    methods: {
        subimt () {
            let _this =this
            if(this.formItem.newpwd ===''||this.formItem.oldpwd===''||this.formItem.confirpwd===''){
                this.$message.error('密码不能为空');
            }else if(this.formItem.newpwd === this.formItem.oldpwd){
                this.$message.error('新密码不能和旧密码一致');
            }else if(this.formItem.newpwd !== this.formItem.confirpwd){
                this.$message.error('两次密码输入不一致');
            }else {
                this.$post('/api/user/editpass',
                    {
                        token:_this.$token,
                        oldpass:_this.formItem.oldpwd,
                        newpass:_this.formItem.newpwd,
                        newpass2:_this.formItem.confirpwd,
                    },function (res) {
                        _this.$message.success(res.msg);

                    },function (err,errmsg,errcode) {
                        _this.$message.error(errmsg);

                    }
                )

            }

        }
    }
}
</script>

<style lang="less" scoped>
  @import "../../../style/style.less";
  .setting-avatar {
    border: 1px solid @border-color;
    border-top: 3px solid @theme-color-dark;
    padding: 15px;
  }
</style>
